var arrow_l = document.getElementsByClassName('arrow_l')[0];
var arrow_r = document.getElementsByClassName('arrow_r')[0];
var banner_box = document.getElementById('banner_box')
console.log(banner_box)
var _index = 0;
// var ul = document.getElementById
for (var i = 0; i < banner_box.children.length; i++) {
  var li = banner_box.children[i];
  li.setAttribute('index', i)

}
var num = li.getAttribute('index');

arrow_l.onclick = function () {
  for (var i = 0; i < banner_box.children.length; i++) {
    var li = banner_box.children[i];
    li.style.opacity = 0;
  }
  num--
  if (num <= -1) {
    num = 7
  }
  _index = num
  banner_box.children[num].style.opacity = 1
}
// 右按钮
arrow_r.onclick = function () {
  for (var i = 0; i < banner_box.children.length; i++) {
    var li = banner_box.children[i];
    li.style.opacity = 0;
  }
  num++
  if (num > 7) {
    num = 0
  }
  _index = num
  banner_box.children[num].style.opacity = 1;
}

setInterval(function () {
  arrow_r.click()
  for (var j = 0; j < circle.children.length; j++) {
    circle.children[j].className = '';
  }
  circle.children[_index].className = 'current'
  console.log(_index)
}, 3000)

// 小圆点
var circle = document.getElementsByClassName('circle')[0]
for (var j = 0; j < banner_box.children.length; j++) {
  var oLi = document.createElement('li');
  circle.appendChild(oLi);
  oLi.setAttribute('index', j);



  oLi.onclick = function () {
    for (var j = 0; j < circle.children.length; j++) {
      circle.children[j].className = '';
    }
    this.className = 'current';
    num = this.getAttribute('index')
    for (var i = 0; i < banner_box.children.length; i++) {
      var li = banner_box.children[i];
      li.style.opacity = 0;
    }
    banner_box.children[num].style.opacity = 1;
  }
}

// 轮播图结束

// 菜单栏
var menu_item = document.getElementsByClassName('menu_item');
var menu_item_info_box = document.getElementsByClassName('menu_item_info_box')[0];
var menuSon = menu_item_info_box.children;
var idx = 0;
for (var i = 0; i < menu_item.length; i++) {
  menu_item[i].setAttribute('index', i)

// 鼠标经过
  menu_item[i].onmouseenter = function () {
    var current = this.getAttribute('index');
    for (var j = 0; j < menuSon.length; j++) {
      menuSon[j].setAttribute('index', j)
      menuSon[j].style.display = 'none';
    }
    menuSon[current].style.display = 'block';
  }
  // 鼠标离开
  menu_item[i].onmouseleave = function () {
    for (var j = 0; j < menuSon.length; j++) {
      menuSon[j].style.display = 'none';
    }
  }
}

